package com.fsnbigdata.service.impl;
import com.fsnbigdata.service.api.ProductEnterpriseService;
import org.springframework.roo.addon.layers.service.annotations.RooServiceImpl;
import com.fsnbigdata.domain.Product;
import com.fsnbigdata.domain.ProductEnterprise;
import com.fsnbigdata.repository.ProductEnterpriseRepository;
import io.springlets.data.domain.GlobalSearch;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * = ProductEnterpriseServiceImpl
 *
 * TODO Auto-generated class documentation
 *
 */
@RooServiceImpl(service = ProductEnterpriseService.class)
@Service
@Transactional(readOnly = true)
public class ProductEnterpriseServiceImpl implements ProductEnterpriseService {

    /**
     * TODO Auto-generated attribute documentation
     *
     */
    private ProductEnterpriseRepository productEnterpriseRepository;

    /**
     * TODO Auto-generated constructor documentation
     *
     * @param productEnterpriseRepository
     */
    @Autowired
    public ProductEnterpriseServiceImpl(ProductEnterpriseRepository productEnterpriseRepository) {
        setProductEnterpriseRepository(productEnterpriseRepository);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return ProductEnterpriseRepository
     */
    public ProductEnterpriseRepository getProductEnterpriseRepository() {
        return productEnterpriseRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param productEnterpriseRepository
     */
    public void setProductEnterpriseRepository(ProductEnterpriseRepository productEnterpriseRepository) {
        this.productEnterpriseRepository = productEnterpriseRepository;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param entity
     * @return ProductEnterprise
     */
    @Transactional
    public ProductEnterprise save(ProductEnterprise entity) {
        return getProductEnterpriseRepository().save(entity);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return ProductEnterprise
     */
    public ProductEnterprise findOne(Long id) {
        return getProductEnterpriseRepository().findOne(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param id
     * @return ProductEnterprise
     */
    public ProductEnterprise findOneForUpdate(Long id) {
        return getProductEnterpriseRepository().findOneDetached(id);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param ids
     * @return List
     */
    public List<ProductEnterprise> findAll(Iterable<Long> ids) {
        return getProductEnterpriseRepository().findAll(ids);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param product
     * @param globalSearch
     * @param pageable
     * @return Page
     */
    public Page<ProductEnterprise> findByProduct(Product product, GlobalSearch globalSearch, Pageable pageable) {
        return getProductEnterpriseRepository().findByProduct(product, globalSearch, pageable);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @param product
     * @return Long
     */
    public long countByProduct(Product product) {
        return getProductEnterpriseRepository().countByProduct(product);
    }

    @Override
    public List<Long> getIdsByName(String name) {
        return getProductEnterpriseRepository().getIdsByName(name);
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<ProductEnterprise> getEntityType() {
        return ProductEnterprise.class;
    }

    /**
     * TODO Auto-generated method documentation
     *
     * @return Class
     */
    public Class<Long> getIdType() {
        return Long.class;
    }
}
